<template>
  <div class="login-from">
    <el-card shadow="always">
      <el-tabs v-model="activeName" type="border-card" stretch>
        <el-tab-pane name="user">
          <template #label>
            <div class="label">
              <User style="width: 1.2em; height: 1.2em" />
              <span class="text">账号登录</span>
            </div>
          </template>
          <PanelAccount ref="paneAccountRef" />
        </el-tab-pane>
        <el-tab-pane name="phone">
          <template #label>
            <div class="label">
              <Iphone style="width: 1.2em; height: 1.2em" />
              <span class="text">手机登录</span>
            </div>
          </template>
          <PanelPhone ref="panelPhoneRef" />
        </el-tab-pane>
      </el-tabs>
    </el-card>
  </div>
</template>

<script setup lang="ts">
import { ref } from 'vue';
// import { ElMessage } from 'element-plus';
import PanelAccount from './panel-account.vue';
import PanelPhone from './panel-phone.vue';

const activeName = ref('user');
// InstanceType 拿到我们的实例类型 就是构造器返回值的类型 就是想要
const paneAccountRef = ref<InstanceType<typeof PanelAccount>>();

const fromSubmitFn = () => {
  if (activeName.value === 'user') {
    paneAccountRef?.value?.submitForm();
  } else {
    console.log('手机号');
  }
};

defineExpose({
  fromSubmitFn
});
</script>

<style lang="less" scoped>
.login-from {
  .label {
    display: flex;
    align-items: center;
    justify-content: center;

    .text {
      margin-left: 8px;
      font-size: 16px;
    }
  }
}
</style>
